package tt.dz.appserver.dao.ext;

import java.util.List;

import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Repository;

import tt.dz.appserver.dao.base.BasisDao;
import tt.dz.appserver.entity.model.pub.Images;


/**
 * 公共图片操作dao
 * @author Administrator
 *
 */
@Repository
public class ImagesDao extends BasisDao<Images>{

	

	@CacheEvict(value="pubImages",key="#obj.associated_type+#obj.image_type+#obj.associated_id")
	@Override
	public int save(Images obj) {
		return super.save(obj);
	}

	@CacheEvict(value="pubImages",key="#obj.associated_type+#obj.image_type+#obj.associated_id")
	@Override
	public int delete(Images obj) {
		return super.delete(obj);
	}
	
	/**
	 * 通过 关联类型 关联ID 和 图片大小 查询图片列表
	 * @param associatedType
	 * @param imageType
	 * @param associatedId
	 * @return
	 */
	@Cacheable(value="pubImages",key="#associatedType+#imageType+#associatedId")
	public List<Images> findImagesListByImagesAssociatedTypeAndImageTypeAndAssociatedId(Integer associatedType, Integer imageType, String associatedId){
		Images images = new Images();
		images.setValid_flag(1);
		images.setImage_type(imageType);
		images.setAssociated_type(associatedType);
		images.setAssociated_id(associatedId);
		List<Images> imagesList = super.findExample(images, null, null, "image_serial_no", 1);
		return imagesList;
	}
}
